package com.happyclub.pojo;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.sql.Time;
import java.util.Date;
import java.util.Objects;

/**
 * @author 高欢
 * @description TODO
 * @date 2019/4/4
 */
@Entity
@Table(name = "TB_SHOPCAR", schema = "SCOTT")
@EntityListeners(AuditingEntityListener.class)
public class TbShopcar {
    private String id;
    private String productId;
    private Long num;
    private String color;
    private String size;
    private String userId;
    private Date updateTime;
    private Date createTime;
    private TbProduct product;

    @Transient
    public TbProduct getProduct() {
        return product;
    }

    public void setProduct(TbProduct product) {
        this.product = product;
    }

    @Id
    @Column(name = "ID")
    @GenericGenerator(name="idGenerator", strategy="uuid") //这个是hibernate的注解/生成32位UUID
    @GeneratedValue(generator="idGenerator")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }


    @Column(name = "PRODUCT_ID")
    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    @Basic
    @Column(name = "NUM")
    public Long getNum() {
        return num;
    }

    public void setNum(Long num) {
        this.num = num;
    }

    @Basic
    @Column(name = "COLOR")
    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Basic
    @Column(name = "SIZEE")
    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    @Basic
    @Column(name = "USER_ID")
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "UPDATE_TIME")
    @LastModifiedDate
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    @CreatedDate
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TbShopcar tbShopcar = (TbShopcar) o;
        return Objects.equals(id, tbShopcar.id) &&
                Objects.equals(productId, tbShopcar.productId) &&
                Objects.equals(num, tbShopcar.num) &&
                Objects.equals(color, tbShopcar.color) &&
                Objects.equals(size, tbShopcar.size) &&
                Objects.equals(userId, tbShopcar.userId) &&
                Objects.equals(updateTime, tbShopcar.updateTime) &&
                Objects.equals(createTime, tbShopcar.createTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, productId, num, color, size, userId, updateTime, createTime);
    }
}
